<?php
	$cart=$this->session->userdata('Cart');
	$shop=rtrim($cart['shop'],'|');
    $arrShop=explode('|',$shop);
    $n=count($arrShop);
    $prcie_all='';
?>
<?php if($arrShop[0] !=''){?>
<div class="checkout right"><a href="<?=PATH_URL.'gio-hang/thanh-toan'?>">Thanh toán</a></div>
<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <th></th>
        <th width="340px">Sản phẩm</th>
        <th width="135px">Giá</th>
        <th width="80px">Số lượng</th>              
        <th width="150px">Tổng cộng</th>
    </tr>
    <?php 
        $shop=rtrim($cart['shop'],'|');
        $arrShop=explode('|',$shop);
        $n=count($arrShop);
        $prcie_all='';
        for($i=0;$i<$n;$i++){
            $arrTmp=explode(',',$arrShop[$i]);
            $result=$this->productsModel->getOne($arrTmp[0]);
            if($result[0]->price_new !=0 && $result[0]->promotion !=0){
				$price=$result[0]->price_new * $arrTmp[1];
			}else{
				$price=$result[0]->price_old * $arrTmp[1];
			}
            $prcie_all +=$price;
    ?>
    <tr>
        <td><img src="<?=PATH_URL.IMAGES_PRODUCTS.$result[0]->image?>" width="100" height="100" /></td>
        <td><a href="<?=PATH_URL.'san-pham/chi-tiet/'.$arrTmp[0].''?>"><?=$result[0]->title;?></a></td>
        <td align="center" class="price">					
			<?php if($result[0]->price_new != 0 && $result[0]->promotion != 0){?>
                <?=number_format($result[0]->price_new,0,',','.');?> vnđ
            <?php }else{?>
                <?=number_format($result[0]->price_old,0,',','.');?> vnđ
            <?php }?>
        </td>
        <td class="cart_num">
            <input type="text" value="<?=$arrTmp[1]?>" name="" id="qtyCart_<?=$arrTmp[0];?>" />
            <img title="Cập nhật" onclick="upCart(<?=$arrTmp[0]?>);" src="<?=PATH_URL.'static/images/refresh.png'?>" width="16" height="16" />
            <img title="Xóa" onclick="delCart(<?=$arrTmp[0]?>);" src="<?=PATH_URL.'static/images/btn_trash.gif'?>" width="16" height="16"/>
        </td>             
        <td align="center" class="price"><?=number_format($price,0,',','.');?> vnđ</td>
    </tr>
    <?php }?>
    <tr>
        <td align="right" colspan="4"><b style="color:#7E8DF8;font-size: 20px">Tổng giá tiền</b></td>
        <td align="center" class="price"><?=number_format($prcie_all,0,',','.');?> vnđ</td>
    </tr>
    <tr>
        <td colspan="5">
            <div class="button left"><a href="<?=PATH_URL?>">Tiếp tục mua hàng</a></div>
            <div class="button right"><a onClick="eraseCart(); return false;" href="">Xóa giỏ hàng</a></div>
        </td>
    </tr>
</table>
<?php }else{?>
	<h4 class="left" style="margin-top: 20px;width: 100%;">Không có sản phẩm nào trong giỏ hàng của bạn</h4>
    <div class="button right" style="margin-top: 20px;"><a href="<?=PATH_URL?>">Tiếp tục mua hàng</a></div>
<?php }?>